package com.example.fenye1.controller;

import com.alibaba.fastjson.JSON;
import com.example.fenye1.entity.PageRequest;
import com.example.fenye1.service.UserService;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @PostMapping("/findPage")
    public String findPage(@RequestBody PageRequest pageRequest) {
        return JSON.toJSONString(userService.findUserByPage(pageRequest));
    }

    @DeleteMapping("user/{id}")
    public String deleteById(@PathVariable Integer id) {
        System.out.println(id);
        return userService.deleteById(id);
    }

}
